<?php
/**
 * Created by PhpStorm.
 * User: HS032
 * Date: 2020/9/2
 * Time: 11:15
 */

namespace ticket\modules\backend\models;

use Yii;

class Syslog extends \yii\db\ActiveRecord
{
    public static function tableName()
    {
        return 'tk_sys_log';
    }

    public function rules()
    {
        return [
            ['username', 'required', 'message' => '用户名不能为空'],
            // ['login_add', 'required', 'message' => '登录地址不能为空'],
            ['login_ip', 'required', 'message' => '登录IP不能为空'],
            ['content', 'required', 'message' => '日志内容不能为空'],
            ['content', 'string', 'max' => 300],
            ['operate_time', 'safe'],
        ];
    }

    /*添加系统日志*/
    public  function addInfo($params)
    {
        if ($this->load($params) and $this->validate()){
            if ($this->save(0)){
                return true;
            }
        }

        return false;
    }



}